home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 1998 November / IRIX 6.5.2 Base Documentation November 1998.img / usr / share / catman / u_man / cat3 / Tcl / scan.z / scan
Text File  |  1998-10-30  |  7KB  |  133 lines

  1.  
  2.  
  3.  
  4. ssssccccaaaannnn((((3333TTTTccccllll))))                                                          ssssccccaaaannnn((((3333TTTTccccllll))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      scan - Parse string using conversion specifiers in the style of sscanf
  10.  
  11. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.      ssssccccaaaannnn _s_t_r_i_n_g _f_o_r_m_a_t _v_a_r_N_a_m_e ?_v_a_r_N_a_m_e ...?
  13.  
  14.  
  15. IIIINNNNTTTTRRRROOOODDDDUUUUCCCCTTTTIIIIOOOONNNN
  16.      This command parses fields from an input string in the same fashion as
  17.      the ANSI C ssssssssccccaaaannnnffff procedure and returns a count of the number of         |
  18.      conversions performed, or -1 if the end of the input string is reached   |
  19.      before any conversions have been performed.  _S_t_r_i_n_g gives the input to be
  20.      parsed and _f_o_r_m_a_t indicates how to parse it, using %%%% conversion
  21.      specifiers as in ssssssssccccaaaannnnffff.  Each _v_a_r_N_a_m_e gives the name of a variable; when
  22.      a field is scanned from _s_t_r_i_n_g the result is converted back into a string
  23.      and assigned to the corresponding variable.
  24.  
  25.  
  26. DDDDEEEETTTTAAAAIIIILLLLSSSS OOOONNNN SSSSCCCCAAAANNNNNNNNIIIINNNNGGGG
  27.      SSSSccccaaaannnn operates by scanning _s_t_r_i_n_g and _f_o_r_m_a_t_S_t_r_i_n_g together.  If the next
  28.      character in _f_o_r_m_a_t_S_t_r_i_n_g is a blank or tab then it matches any number of
  29.      white space characters in _s_t_r_i_n_g (including zero).  Otherwise, if it
  30.      isn't a %%%% character then it must match the next character of _s_t_r_i_n_g.
  31.      When a %%%% is encountered in _f_o_r_m_a_t_S_t_r_i_n_g, it indicates the start of a
  32.      conversion specifier.  A conversion specifier contains three fields after
  33.      the %%%%:  a ****, which indicates that the converted value is to be discarded
  34.      instead of assigned to a variable; a number indicating a maximum field
  35.      width; and a conversion character.  All of these fields are optional
  36.      except for the conversion character.
  37.  
  38.      When ssssccccaaaannnn finds a conversion specifier in _f_o_r_m_a_t_S_t_r_i_n_g, it first skips
  39.      any white-space characters in _s_t_r_i_n_g.  Then it converts the next input
  40.      characters according to the conversion specifier and stores the result in
  41.      the variable given by the next argument to ssssccccaaaannnn.  The following
  42.      conversion characters are supported:
  43.  
  44.      dddd         The input field must be a decimal integer.  It is read in and
  45.                the value is stored in the variable as a decimal string.
  46.  
  47.      oooo         The input field must be an octal integer. It is read in and the
  48.                value is stored in the variable as a decimal string.
  49.  
  50.      xxxx         The input field must be a hexadecimal integer. It is read in
  51.                and the value is stored in the variable as a decimal string.
  52.  
  53.      cccc         A single character is read in and its binary value is stored in
  54.                the variable as a decimal string.  Initial white space is not
  55.                skipped in this case, so the input field may be a white-space
  56.                character.  This conversion is different from the ANSI standard
  57.                in that the input field always consists of a single character
  58.                and no field width may be specified.
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. ssssccccaaaannnn((((3333TTTTccccllll))))                                                          ssssccccaaaannnn((((3333TTTTccccllll))))
  71.  
  72.  
  73.  
  74.      ssss         The input field consists of all the characters up to the next
  75.                white-space character; the characters are copied to the
  76.                variable.
  77.  
  78.      eeee or ffff or gggg
  79.                The input field must be a floating-point number consisting of
  80.                an optional sign, a string of decimal digits possibly
  81.                containing a decimal point, and an optional exponent consisting
  82.                of an eeee or EEEE followed by an optional sign and a string of
  83.                decimal digits.  It is read in and stored in the variable as a
  84.                floating-point string.
  85.  
  86.      [[[[_c_h_a_r_s]]]]   The input field consists of any number of characters in _c_h_a_r_s.
  87.                The matching string is stored in the variable.  If the first
  88.                character between the brackets is a ]]]] then it is treated as
  89.                part of _c_h_a_r_s rather than the closing bracket for the set.
  90.  
  91.      [[[[^^^^_c_h_a_r_s]]]]  The input field consists of any number of characters not in
  92.                _c_h_a_r_s.  The matching string is stored in the variable.  If the
  93.                character immediately following the ^^^^ is a ]]]] then it is treated
  94.                as part of the set rather than the closing bracket for the set.
  95.  
  96.      The number of characters read from the input for a conversion is the
  97.      largest number that makes sense for that particular conversion (e.g.  as
  98.      many decimal digits as possible for %%%%dddd, as many octal digits as possible
  99.      for %%%%oooo, and so on).  The input field for a given conversion terminates
  100.      either when a white-space character is encountered or when the maximum
  101.      field width has been reached, whichever comes first.  If a **** is present
  102.      in the conversion specifier then no variable is assigned and the next
  103.      scan argument is not consumed.
  104.  
  105.  
  106. DDDDIIIIFFFFFFFFEEEERRRREEEENNNNCCCCEEEESSSS FFFFRRRROOOOMMMM AAAANNNNSSSSIIII SSSSSSSSCCCCAAAANNNNFFFF
  107.      The behavior of the ssssccccaaaannnn command is the same as the behavior of the ANSI
  108.      C ssssssssccccaaaannnnffff procedure except for the following differences:
  109.  
  110.      [1]  %%%%pppp and %%%%nnnn conversion specifiers are not currently supported.        |
  111.  
  112.      [2]  For %%%%cccc conversions a single character value is converted to a
  113.           decimal string, which is then assigned to the corresponding _v_a_r_N_a_m_e;
  114.           no field width may be specified for this conversion.
  115.  
  116.      [3]  The llll, hhhh, and LLLL modifiers are ignored;  integer values are always   |
  117.           converted as if there were no modifier present and real values are  |
  118.           always converted as if the llll modifier were present (i.e. type ddddoooouuuubbbblllleeee|
  119.           is used for the internal representation).
  120.  
  121.  
  122. KKKKEEEEYYYYWWWWOOOORRRRDDDDSSSS
  123.      conversion specifier, parse, scan
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.